<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery-3.4.1.js"></script>
</head>
<body>
    用户名：<input type="text" id="username">
    密码：<input type="text" id="password">
    <button type="button" onclick="set()">登陆</button>
    <button type="button" onclick="out()">退出登陆</button>
    <a href="http://localhost:3003/info">去看我自己的私密信息</a>
</body>
<script>
    function set(){
        // 取得输入的用户名和密码
        let uname = $("#username").val()
        let password = $("#password").val()
        // console.log(uname, password);
        $.ajax({
            // 发get请求
            type: "GET",
            url: "http://localhost:3003/set",
            data:{
                username: uname,
                password: password
            },
            success: function(res){
                console.log(res);
            },
            error: function(xhr, ereortype){
                console.log(xhr.status);
            }
        })
    }

    function out(){
        $.ajax({
            // 发get请求
            type: "GET",
            url: "http://localhost:3003/remove",
            success: function(res){
                console.log(res);
            },
            error: function(xhr, ereortype){
                console.log(xhr.status);
            }
        })
    }
</script>
</html>